<template>
  <div>
    <Card
      title="新增售价市场调研"
      :bordered="false"
      dis-hover
      class="ivu-mt i-table-no-border"
    >
      <Row type="flex">
        <Col class="marginTop10" span="8"
          >调研时间：{{ formData.createOpeTime }}</Col
        >
        <Col class="marginTop10" span="8"
          >调研部门：{{ formData.departmentName }}</Col
        >
        <Col class="marginTop10" span="8">调研人：{{ formData.surveyMan }}</Col>
        <Col class="marginTop10" span="8"
          >调研区域：
          {{ formData.surveyArea }}
        </Col>
        <Col class="marginTop10" span="6">单据号：{{ formData.recordNo }}</Col>
        <Col class="marginTop10" span="24"
          >调研目的：
          {{ formData.surveyTarget }}
        </Col>
        <Col class="marginTop10" span="24"
          >调研总结：
          {{ formData.surveyReault }}
        </Col>
      </Row>
      <Row>
        <Table
          :columns="columns1"
          :data="baseTableData"
          width="100%"
          ref="table"
        >
          <template slot-scope="{ row }" slot="salePriceManager">
            <span>{{ row.salePriceManager }}</span>
          </template>
          <template slot-scope="{ row }" slot="cashPriceGrossRate">
            <span>{{ row.cashPriceGrossRate }}</span>
          </template>
          <template slot-scope="{ row }" slot="cashPriceActualRate">
            <span>{{ row.cashPriceActualRate }}</span>
          </template>
          <template slot-scope="{ row }" slot="salePriceGrossRate">
            <span>{{ row.salePriceGrossRate }}</span>
          </template>
          <template slot-scope="{ row }" slot="salePriceActualRate">
            <span>{{ row.salePriceActualRate }}</span>
          </template>
          <template slot-scope="{ row }" slot="cashPriceActualRate">
            <span>{{ row.cashPriceActualRate }}</span>
          </template>
          <template slot-scope="{ row }" slot="orderNo">
            <span>{{ row.orderNo }}</span>
          </template>
          <template slot-scope="{ row }" slot="surveyReaultTypeName">
            <span>{{ row.surveyReaultTypeName }}</span>
          </template>
          <template slot-scope="{ row }" slot="surveyReaultDes">
            <span>{{ row.surveyReaultDes }}</span>
          </template>
          <template slot-scope="{ row }" slot="surveyReaultNote">
            <span>{{ row.surveyReaultNote }}</span>
          </template>
        </Table>
      </Row>
      <Row type="flex" justify="center" style="flex-wrap: wrap; margin: 16px">
        <Button @click="goBack">返回</Button>
      </Row>
    </Card>
  </div>
</template>
<script>
import { ApiRequest } from '@api/basePage';
// import { mapState, mapMutations } from 'vuex';
import tableForm from '@/components/common/baseForm'; // 表单组件
import tableList from './comps/baseTableView'; // 表格组件
import asyncLoadComp from '@/components/common/asyncLoadComp'; // 动态导入组件

export default {
  components: {
    tableForm,
    tableList,
    asyncLoadComp
  },
  data () {
    return {
      getData: [],
      dynamicData: {},
      pagePath: '', // 当前路由
      columns1: [
        {
          title: '分类编码',
          key: 'categoryNo',
          fixed: 'left',
          minWidth: 140
        },
        {
          title: '分类名称',
          key: 'categoryName',
          minWidth: 140
        },
        {
          title: '售价管理周期',
          slot: 'salePriceManager',
          align: 'center',
          minWidth: 140
        },
        {
          title: 'SPU编码',
          key: 'spuNo',
          align: 'center',
          minWidth: 140
        },
        {
          title: 'SKU编码',
          key: 'skuNo',
          align: 'center',
          minWidth: 140
        },
        {
          title: '商品名称',
          key: 'productName',
          align: 'center',
          minWidth: 140
        },
        {
          title: '规格',
          key: 'spec',
          align: 'center',
          minWidth: 140
        },
        {
          title: '商品管理区域',
          key: 'productManagerName',
          align: 'center',
          minWidth: 140
        },
        {
          title: '主单位',
          key: 'mainUnitName',
          align: 'center',
          minWidth: 140
        },
        {
          title: '主单位价格',
          key: 'mainUnitPrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '辅单位',
          key: 'auxiliaryUnitName',
          align: 'center',
          minWidth: 140
        },
        {
          title: '辅单位价格',
          key: 'auxiliaryUnitPrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '价格组',
          key: 'priceGruopName',
          align: 'center',
          minWidth: 140
        },
        {
          title: '面价',
          key: 'facePrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '进价',
          key: 'purchasePrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '成本价',
          key: 'costPrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '现金价',
          key: 'cashPrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '标准毛利率',
          slot: 'cashPriceGrossRate',
          align: 'center',
          minWidth: 140
        },
        {
          title: '实际毛利率',
          slot: 'cashPriceActualRate',
          align: 'center',
          minWidth: 140
        },
        {
          title: '售价',
          key: 'salePrice',
          align: 'center',
          minWidth: 140
        },
        {
          title: '标准毛利率',
          slot: 'salePriceGrossRate',
          align: 'center',
          minWidth: 140
        },
        {
          title: '实际毛利率',
          slot: 'salePriceActualRate',
          align: 'center',
          minWidth: 140
        },
        {
          title: '最近一次调价时间',
          key: 'lastChangeTime',
          align: 'center',
          minWidth: 180
        },
        {
          title: '近12月销售额',
          key: 'lastSaleMoney',
          align: 'center',
          minWidth: 200
        },
        {
          title: '近12月毛利额',
          key: 'lastSaleGrossMoney',
          align: 'center',
          minWidth: 200
        },
        {
          title: '实际毛利率',
          slot: 'lastSaleActualRate',
          align: 'center',
          minWidth: 120
        },
        {
          title: '上游单号',
          slot: 'orderNo',
          align: 'center',
          minWidth: 120
        },
        {
          title: '调研总结',
          align: 'center',
          children: [
            {
              title: '调研结果选择',
              slot: 'surveyReaultTypeName',
              align: 'center',
              width: 140
            },
            {
              title: '调研结果描述',
              slot: 'surveyReaultDes',
              align: 'center',
              width: 140
            },
            {
              title: '审核人意见',
              slot: 'surveyReaultNote',
              align: 'center',
              width: 140
            }
          ]
        }
      ],
      baseTableData: [],
      formData: {
        createOpeTime: '',
        departmentName: '',
        surveyMan: '',
        surveyArea: '',
        recordNo: '',
        surveyTarget: '',
        surveyReault: ''
      },
      recordNo: ''
    };
  },
  computed: {},
  created () {
    this.getConfigData();
  },
  mounted () {},
  methods: {
    // 返回
    goBack () {
      this.$router.go(-1);
    },
    // 获取初始配置信息
    getConfigData () {
      this.recordNo = this.$route.query.recordNo;
      this.initData();
    },
    initData () {
      let data = {};
      ApiRequest(
        `/sysback/salepricesurvey/viewSurveyRecordByRecordNo?recordNo=` +
          this.recordNo,
        'get',
        data
      ).then((res) => {
        this.baseTableData = res.retData.detailList;
        this.formData = res.retData;
      });
    }
  }
};
</script>
